﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;

namespace MVC.Common
{
    public class EmployeeDTO
    {
        public virtual int Id { get; set; }

        public virtual string Name { get; set; }

        public virtual string Address { get; set; }

        public virtual DepartmentDTO Department { get; set; }
    }

    public class EmployeeMap : ClassMap<EmployeeDTO>
    {
        public EmployeeMap()
        {
        Table("Employee");
            Id(emp => emp.Id).GeneratedBy.Identity().Column("Id");
            Map(emp => emp.Name).Column("Name");
            Map(emp => emp.Address).Column("Address");

            References<DepartmentDTO>(x => x.Department, "DeptId")
                .Column("DeptId").Fetch.Join()
                .Cascade.None();
        }
    }
}
